#include<deque>
#include<iostream>
using namespace std;
void putData(deque<int>& d,const string& str){
    cout<<str;
    for(auto val:d)
        cout<<val<<" ";
    cout<<endl;
}
void pushData(deque<int>& d,int n){
    for(int i=0;i<n;i++){
        d.push_back(rand()%100);//末尾插入元素
        d.push_front(rand()%100-100);//开头插入元素
    }
}
void popData(deque<int>& d){
    int n=d.size();
    for(int i=0;i<n;i++)
        if(i%2==0)d.pop_back();//末尾删除
        else d.pop_front();//开头删除
}
int main(){
    deque<int>dq;
    pushData(dq,10);
    putData(dq,"原始数据：");
    dq.insert(dq.begin()+2,666);
    putData(dq,"插入数据：");
    dq.erase(dq.end()-3);
    putData(dq,"单个删除：");
    popData(dq);
    dq.clear();
} // namespace std;
